﻿using System;
using WFC.BL.Repositories;
using WFC.BL.Interfaces.DomainModels;
using WFC.BL.Interfaces.Enumerations;
using WFC.BL.Interfaces.Repositories;
using WFC.BL.Services.Interfaces;

namespace WFC.BL.Services
{
    public class ContentService : IContentService
    {

        private IRepositoryFacade Repository { get; set; }

        /// <summary>
        /// Default constructor
        /// </summary>
        public ContentService()
        {
            Repository = new RepositoryFacade();
        }

        #region IContentService Members

        public int InsertContents(CmsPageMode cmsPageMode, string htmlContent, int createdBy)
        {
            if (String.IsNullOrEmpty(htmlContent))
                throw new ArgumentNullException("htmlContent");

            if (createdBy < 1)
                throw new ArgumentNullException("createdBy");

            return Repository.InsertContents(cmsPageMode, htmlContent, createdBy);
        }

        public IContentMaintainable ReadContentsById(int contentId)
        {
            if (contentId < 1)
                throw new ArgumentNullException("contentId");

            return Repository.ReadContentsById(contentId);
        }

        public bool UpdateContents(IContentMaintainable content, int updatedBy)
        {
            if (content == null)
                throw new ArgumentNullException("content");

            if (updatedBy < 1)
                throw new ArgumentNullException("updatedBy");

            content.UpdatedBy = updatedBy;
            return Repository.UpdateContents(content);
        }

        public bool DeleteContents(int contentId)
        {
            if (contentId < 1)
                throw new ArgumentNullException("contentId");

            return Repository.DeleteContents(contentId);
        }

        #endregion

    }
}
